package com.jie.mc.event;


import com.jie.mc.Main;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

public class Entityevent implements Listener {

    @EventHandler
    public void EntityDamage(EntityDamageByEntityEvent event){
        Entity damager = event.getDamager();
        Main.plugin.getLogger().info("攻击事件监听到");
        if (damager.getType()== EntityType.PLAYER){
            //攻击的人是玩家
            Entity entity = event.getEntity();
            Player player = (Player) damager;

            if (player.getName().equalsIgnoreCase("jie")){
                event.setDamage(1000);
            }else {
                event.setCancelled(true);
            }
            if (event.getEntityType()==EntityType.PIG){
                double damage = event.getDamage();
                event.setDamage(damage+10);
            }
        }
    }
}
